#include "HereMyName.h"

using namespace std;

void main()
{


	string confirm;
	long lsend;
	long lrecv;
	WSAData wsaData;
	WORD DLLVersion;
	DLLVersion = MAKEWORD(2, 1);
	lsend = WSAStartup(DLLVersion, &wsaData);
	lrecv = WSAStartup(DLLVersion, &wsaData);
	SOCKADDR_IN addr;
	int addrlen = sizeof(addr);

	SOCKET sConnect;
	sConnect = socket(AF_INET, SOCK_STREAM, NULL);

	addr.sin_addr.s_addr = inet_addr("127.0.0.1");
	addr.sin_family = AF_INET;
	addr.sin_port = htons(1234);

	cout << "Do you want to connect to your server? [y]/[n]" << endl;
	cin >> confirm;
	if (confirm == "N" || confirm == "n")
		exit(1);
	else
	{
		if (confirm == "Y" || confirm == "y")
		{
			cout << "Done!" << endl;
			connect(sConnect, (SOCKADDR*) &addr, addrlen);
			while (1)
			{
				char *msSend;
				char *msRecv;
				char *Temp;
				msRecv = new char[1024];
				msSend = new char[1024];
				string mss;
				lrecv = recv(sConnect, msRecv, strlen(msRecv), NULL);
				mss = msRecv;
				cout << "The F*in' Message from Server: " << mss << endl;
				
				cout << "Type something send to the F*kin' server: ";
				_flushall();
				gets_s(msSend, 1023);
				Temp = new char[strlen(msSend) + 1];
				strcpy_s(Temp, strlen(msSend) + 1, msSend);
				lsend = send(sConnect, Temp, strlen(Temp) + 1, NULL);
				
				
				delete []Temp;
				delete []msRecv;
				msRecv = NULL;
				delete [] msSend;
				msSend = NULL;
			}
		}
	}
}